{
 "cells": [
  {
   "cell_type": "markdown",
   "id": "f44a2f2b",
   "metadata": {},
   "source": [
    "# 100 numpy exercises\n",
    "\n",
    "This is a collection of exercises that have been collected in the numpy mailing list, on stack overflow\n",
    "and in the numpy documentation. The goal of this collection is to offer a quick reference for both old\n",
    "and new users but also to provide a set of exercises for those who teach.\n",
    "\n",
    "\n",
    "If you find an error or think you've a better way to solve some of them, feel\n",
    "free to open an issue at <https://github.com/rougier/numpy-100>."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "0fe3d529",
   "metadata": {},
   "source": [
    "File automatically generated. See the documentation to update questions/answers/hints programmatically."
   ]
  },
  {
   "cell_type": "markdown",
   "id": "23296a93",
   "metadata": {},
   "source": [
    "Run the `initialize.py` module, then for each question you can query the\n",
    "answer or an hint with `hint(n)` or `answer(n)` for `n` question number."
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "530390cf",
   "metadata": {},
   "outputs": [],
   "source": [
    "%run initialise.py"
   ]
  },
  {
   "cell_type": "markdown",
   "id": "96443564",
   "metadata": {},
   "source": [
    "#### 1. Import the numpy package under the name `np` (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ffe1047e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c807bf1d",
   "metadata": {},
   "source": [
    "#### 2. Print the numpy version and the configuration (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f396b717",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "572c1bdb",
   "metadata": {},
   "source": [
    "#### 3. Create a null vector of size 10 (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31c9f6a5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "337e6e36",
   "metadata": {},
   "source": [
    "#### 4. How to find the memory size of any array (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "31e8ec2e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "166079c8",
   "metadata": {},
   "source": [
    "#### 5. How to get the documentation of the numpy add function from the command line? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "593cd80f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "3add7101",
   "metadata": {},
   "source": [
    "#### 6. Create a null vector of size 10 but the fifth value which is 1 (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2edf3c42",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "cfc46304",
   "metadata": {},
   "source": [
    "#### 7. Create a vector with values ranging from 10 to 49 (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d8b86640",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "0cc200be",
   "metadata": {},
   "source": [
    "#### 8. Reverse a vector (first element becomes last) (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec044bb5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "29d9ede4",
   "metadata": {},
   "source": [
    "#### 9. Create a 3x3 matrix with values ranging from 0 to 8 (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d9e39043",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "88905ceb",
   "metadata": {},
   "source": [
    "#### 10. Find indices of non-zero elements from [1,2,0,0,4,0] (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b2f3c90a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "49603e91",
   "metadata": {},
   "source": [
    "#### 11. Create a 3x3 identity matrix (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5b607b5c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e15c249a",
   "metadata": {},
   "source": [
    "#### 12. Create a 3x3x3 array with random values (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ab21ed50",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "157a129c",
   "metadata": {},
   "source": [
    "#### 13. Create a 10x10 array with random values and find the minimum and maximum values (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c0066de5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "d92d7b32",
   "metadata": {},
   "source": [
    "#### 14. Create a random vector of size 30 and find the mean value (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9672d023",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f361efc0",
   "metadata": {},
   "source": [
    "#### 15. Create a 2d array with 1 on the border and 0 inside (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a55b6666",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "475808cb",
   "metadata": {},
   "source": [
    "#### 16. How to add a border (filled with 0's) around an existing array? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b2df3a8a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1af07d85",
   "metadata": {},
   "source": [
    "#### 17. What is the result of the following expression? (★☆☆)\n",
    "```python\n",
    "0 * np.nan\n",
    "np.nan == np.nan\n",
    "np.inf > np.nan\n",
    "np.nan - np.nan\n",
    "np.nan in set([np.nan])\n",
    "0.3 == 3 * 0.1\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "109cf327",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6a235316",
   "metadata": {},
   "source": [
    "#### 18. Create a 5x5 matrix with values 1,2,3,4 just below the diagonal (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f2e6cfa6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "25362e98",
   "metadata": {},
   "source": [
    "#### 19. Create a 8x8 matrix and fill it with a checkerboard pattern (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cabdf298",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6431e977",
   "metadata": {},
   "source": [
    "#### 20. Consider a (6,7,8) shape array, what is the index (x,y,z) of the 100th element? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "de8b0245",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "31abe6fe",
   "metadata": {},
   "source": [
    "#### 21. Create a checkerboard 8x8 matrix using the tile function (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "6da26fd3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "fd88b3f4",
   "metadata": {},
   "source": [
    "#### 22. Normalize a 5x5 random matrix (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ee6ced60",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "464d8590",
   "metadata": {},
   "source": [
    "#### 23. Create a custom dtype that describes a color as four unsigned bytes (RGBA) (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e2f9cfc6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "06c63bb3",
   "metadata": {},
   "source": [
    "#### 24. Multiply a 5x3 matrix by a 3x2 matrix (real matrix product) (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9fc0d553",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "76fa6285",
   "metadata": {},
   "source": [
    "#### 25. Given a 1D array, negate all elements which are between 3 and 8, in place. (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0e25eca7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "930ed8bb",
   "metadata": {},
   "source": [
    "#### 26. What is the output of the following script? (★☆☆)\n",
    "```python\n",
    "# Author: Jake VanderPlas\n",
    "\n",
    "print(sum(range(5),-1))\n",
    "from numpy import *\n",
    "print(sum(range(5),-1))\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f02eedba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "177120e7",
   "metadata": {},
   "source": [
    "#### 27. Consider an integer vector Z, which of these expressions are legal? (★☆☆)\n",
    "```python\n",
    "Z**Z\n",
    "2 << Z >> 2\n",
    "Z <- Z\n",
    "1j*Z\n",
    "Z/1/1\n",
    "Z<Z>Z\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "86d6cbef",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a6eaf0e8",
   "metadata": {},
   "source": [
    "#### 28. What are the result of the following expressions? (★☆☆)\n",
    "```python\n",
    "np.array(0) / np.array(0)\n",
    "np.array(0) // np.array(0)\n",
    "np.array([np.nan]).astype(int).astype(float)\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "93684068",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "524b65f8",
   "metadata": {},
   "source": [
    "#### 29. How to round away from zero a float array ? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "61fbb78e",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "8dc40752",
   "metadata": {},
   "source": [
    "#### 30. How to find common values between two arrays? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "54399cbe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b7f38e21",
   "metadata": {},
   "source": [
    "#### 31. How to ignore all numpy warnings (not recommended)? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "2ca3289c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "2d850aab",
   "metadata": {},
   "source": [
    "#### 32. Is the following expressions true? (★☆☆)\n",
    "```python\n",
    "np.sqrt(-1) == np.emath.sqrt(-1)\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5c83ffce",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "5c4a556f",
   "metadata": {},
   "source": [
    "#### 33. How to get the dates of yesterday, today and tomorrow? (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c3b683a0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "453cdd64",
   "metadata": {},
   "source": [
    "#### 34. How to get all the dates corresponding to the month of July 2016? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4ba4d37c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "52667b6e",
   "metadata": {},
   "source": [
    "#### 35. How to compute ((A+B)*(-A/2)) in place (without copy)? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6e7c030",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "9a8f3738",
   "metadata": {},
   "source": [
    "#### 36. Extract the integer part of a random array of positive numbers using 4 different methods (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "368a801a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "cab1eed1",
   "metadata": {},
   "source": [
    "#### 37. Create a 5x5 matrix with row values ranging from 0 to 4 (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f1b579ba",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "cd0ce6b1",
   "metadata": {},
   "source": [
    "#### 38. Consider a generator function that generates 10 integers and use it to build an array (★☆☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "aab193a6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c4c942d1",
   "metadata": {},
   "source": [
    "#### 39. Create a vector of size 10 with values ranging from 0 to 1, both excluded (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e42eaa4b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "9b3cb8d2",
   "metadata": {},
   "source": [
    "#### 40. Create a random vector of size 10 and sort it (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "37d2b341",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "2facfddc",
   "metadata": {},
   "source": [
    "#### 41. How to sum a small array faster than np.sum? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "4bb8864f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "539cd2a5",
   "metadata": {},
   "source": [
    "#### 42. Consider two random array A and B, check if they are equal (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5246d7bf",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "448f8274",
   "metadata": {},
   "source": [
    "#### 43. Make an array immutable (read-only) (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7cf2b3dd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "d7b7aaf3",
   "metadata": {},
   "source": [
    "#### 44. Consider a random 10x2 matrix representing cartesian coordinates, convert them to polar coordinates (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e2337585",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a556027a",
   "metadata": {},
   "source": [
    "#### 45. Create random vector of size 10 and replace the maximum value by 0 (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9e07cb87",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "004f3da1",
   "metadata": {},
   "source": [
    "#### 46. Create a structured array with `x` and `y` coordinates covering the [0,1]x[0,1] area (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b3824741",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1c0adc0d",
   "metadata": {},
   "source": [
    "#### 47. Given two arrays, X and Y, construct the Cauchy matrix C (Cij =1/(xi - yj)) (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "01b3bbb7",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c8a2f65a",
   "metadata": {},
   "source": [
    "#### 48. Print the minimum and maximum representable value for each numpy scalar type (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "35d844d6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "11727a69",
   "metadata": {},
   "source": [
    "#### 49. How to print all the values of an array? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "47e98473",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e0e7d741",
   "metadata": {},
   "source": [
    "#### 50. How to find the closest value (to a given scalar) in a vector? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "62cabf6f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c5611b9e",
   "metadata": {},
   "source": [
    "#### 51. Create a structured array representing a position (x,y) and a color (r,g,b) (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f622939d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "d22b8574",
   "metadata": {},
   "source": [
    "#### 52. Consider a random vector with shape (100,2) representing coordinates, find point by point distances (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d5c9cdf8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f5c164f2",
   "metadata": {},
   "source": [
    "#### 53. How to convert a float (32 bits) array into an integer (32 bits) in place?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ea262de8",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a8b7e6f5",
   "metadata": {},
   "source": [
    "#### 54. How to read the following file? (★★☆)\n",
    "```\n",
    "1, 2, 3, 4, 5\n",
    "6,  ,  , 7, 8\n",
    " ,  , 9,10,11\n",
    "```"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "bde0538a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c6b32834",
   "metadata": {},
   "source": [
    "#### 55. What is the equivalent of enumerate for numpy arrays? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ab02472a",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a2121a05",
   "metadata": {},
   "source": [
    "#### 56. Generate a generic 2D Gaussian-like array (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "18507102",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "97055efa",
   "metadata": {},
   "source": [
    "#### 57. How to randomly place p elements in a 2D array? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "292e842f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "bfd2513c",
   "metadata": {},
   "source": [
    "#### 58. Subtract the mean of each row of a matrix (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f306ab72",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "da9f2f9b",
   "metadata": {},
   "source": [
    "#### 59. How to sort an array by the nth column? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "68cde57f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "5b7be45c",
   "metadata": {},
   "source": [
    "#### 60. How to tell if a given 2D array has null columns? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "7dbe2c27",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "7c18c02e",
   "metadata": {},
   "source": [
    "#### 61. Find the nearest value from a given value in an array (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b78ae9c4",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "8174ba2c",
   "metadata": {},
   "source": [
    "#### 62. Considering two arrays with shape (1,3) and (3,1), how to compute their sum using an iterator? (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8a18fe57",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "9189bd7c",
   "metadata": {},
   "source": [
    "#### 63. Create an array class that has a name attribute (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1c01ed42",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f30162d2",
   "metadata": {},
   "source": [
    "#### 64. Consider a given vector, how to add 1 to each element indexed by a second vector (be careful with repeated indices)? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "093ba36f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f5b1c584",
   "metadata": {},
   "source": [
    "#### 65. How to accumulate elements of a vector (X) to an array (F) based on an index list (I)? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "c9d92a75",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "994c452d",
   "metadata": {},
   "source": [
    "#### 66. Considering a (w,h,3) image of (dtype=ubyte), compute the number of unique colors (★★☆)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "269cdaea",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "4bddeb31",
   "metadata": {},
   "source": [
    "#### 67. Considering a four dimensions array, how to get sum over the last two axis at once? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "32af15f5",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c4cf083c",
   "metadata": {},
   "source": [
    "#### 68. Considering a one-dimensional vector D, how to compute means of subsets of D using a vector S of same size describing subset  indices? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9600a2dd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a5e316db",
   "metadata": {},
   "source": [
    "#### 69. How to get the diagonal of a dot product? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "94735dbd",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "de727a7b",
   "metadata": {},
   "source": [
    "#### 70. Consider the vector [1, 2, 3, 4, 5], how to build a new vector with 3 consecutive zeros interleaved between each value? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "982be812",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a9a73d6b",
   "metadata": {},
   "source": [
    "#### 71. Consider an array of dimension (5,5,3), how to mulitply it by an array with dimensions (5,5)? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "282a90cc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a951c78f",
   "metadata": {},
   "source": [
    "#### 72. How to swap two rows of an array? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e29b3fde",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "43b639e8",
   "metadata": {},
   "source": [
    "#### 73. Consider a set of 10 triplets describing 10 triangles (with shared vertices), find the set of unique line segments composing all the  triangles (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "147e1034",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "d41de585",
   "metadata": {},
   "source": [
    "#### 74. Given a sorted array C that corresponds to a bincount, how to produce an array A such that np.bincount(A) == C? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "5f5d6e36",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b50adf7c",
   "metadata": {},
   "source": [
    "#### 75. How to compute averages using a sliding window over an array? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e631a9d2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1ab4c50d",
   "metadata": {},
   "source": [
    "#### 76. Consider a one-dimensional array Z, build a two-dimensional array whose first row is (Z[0],Z[1],Z[2]) and each subsequent row is  shifted by 1 (last row should be (Z[-3],Z[-2],Z[-1]) (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3ccfe2c0",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "5b4fe59d",
   "metadata": {},
   "source": [
    "#### 77. How to negate a boolean, or to change the sign of a float inplace? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "3c2373ff",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "119ab5af",
   "metadata": {},
   "source": [
    "#### 78. Consider 2 sets of points P0,P1 describing lines (2d) and a point p, how to compute distance from p to each line i (P0[i],P1[i])? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "1d8d06dc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "e5e7f323",
   "metadata": {},
   "source": [
    "#### 79. Consider 2 sets of points P0,P1 describing lines (2d) and a set of points P, how to compute distance from each point j (P[j]) to each line i (P0[i],P1[i])? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d0ce77e2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "9b9d03eb",
   "metadata": {},
   "source": [
    "#### 80. Consider an arbitrary array, write a function that extract a subpart with a fixed shape and centered on a given element (pad with a `fill` value when necessary) (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "ec2b7ae3",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "27794913",
   "metadata": {},
   "source": [
    "#### 81. Consider an array Z = [1,2,3,4,5,6,7,8,9,10,11,12,13,14], how to generate an array R = [[1,2,3,4], [2,3,4,5], [3,4,5,6], ..., [11,12,13,14]]? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "f3e7878b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "fae786f5",
   "metadata": {},
   "source": [
    "#### 82. Compute a matrix rank (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "64b9615b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "c85aa0b9",
   "metadata": {},
   "source": [
    "#### 83. How to find the most frequent value in an array?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "056be85b",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "0ff2344d",
   "metadata": {},
   "source": [
    "#### 84. Extract all the contiguous 3x3 blocks from a random 10x10 matrix (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "d58b1318",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "1a18b263",
   "metadata": {},
   "source": [
    "#### 85. Create a 2D array subclass such that Z[i,j] == Z[j,i] (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "87f17adc",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "f85f2cad",
   "metadata": {},
   "source": [
    "#### 86. Consider a set of p matrices wich shape (n,n) and a set of p vectors with shape (n,1). How to compute the sum of of the p matrix products at once? (result has shape (n,1)) (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "8d230557",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "5afb72c8",
   "metadata": {},
   "source": [
    "#### 87. Consider a 16x16 array, how to get the block-sum (block size is 4x4)? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e86f47a9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "6094d37c",
   "metadata": {},
   "source": [
    "#### 88. How to implement the Game of Life using numpy arrays? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a93e715f",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a173cf96",
   "metadata": {},
   "source": [
    "#### 89. How to get the n largest values of an array (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b7c2ff35",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "15db2d01",
   "metadata": {},
   "source": [
    "#### 90. Given an arbitrary number of vectors, build the cartesian product (every combinations of every item) (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a9a4633d",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "5d94d1ef",
   "metadata": {},
   "source": [
    "#### 91. How to create a record array from a regular array? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "b1dae380",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "114ccc36",
   "metadata": {},
   "source": [
    "#### 92. Consider a large vector Z, compute Z to the power of 3 using 3 different methods (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "877c65d6",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "d614fee4",
   "metadata": {},
   "source": [
    "#### 93. Consider two arrays A and B of shape (8,3) and (2,2). How to find rows of A that contain elements of each row of B regardless of the order of the elements in B? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "e6807a84",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "b0eedca6",
   "metadata": {},
   "source": [
    "#### 94. Considering a 10x3 matrix, extract rows with unequal values (e.g. [2,2,3]) (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "fc136ce2",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "a65ec1cf",
   "metadata": {},
   "source": [
    "#### 95. Convert a vector of ints into a matrix binary representation (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "323cdf4c",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "75b9397f",
   "metadata": {},
   "source": [
    "#### 96. Given a two dimensional array, how to extract unique rows? (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "9bb56a47",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "82aaf21b",
   "metadata": {},
   "source": [
    "#### 97. Considering 2 vectors A & B, write the einsum equivalent of inner, outer, sum, and mul function (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "cedcefd9",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "7741e17f",
   "metadata": {},
   "source": [
    "#### 98. Considering a path described by two vectors (X,Y), how to sample it using equidistant samples (★★★)?"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "0b2432fe",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "340d6f36",
   "metadata": {},
   "source": [
    "#### 99. Given an integer n and a 2D array X, select from X the rows which can be interpreted as draws from a multinomial distribution with n degrees, i.e., the rows which only contain integers and which sum to n. (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "a75323ae",
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "markdown",
   "id": "19721849",
   "metadata": {},
   "source": [
    "#### 100. Compute bootstrapped 95% confidence intervals for the mean of a 1D array X (i.e., resample the elements of an array with replacement N times, compute the mean of each sample, and then compute percentiles over the means). (★★★)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "id": "87309c6f",
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {},
 "nbformat": 4,
 "nbformat_minor": 5
}
